
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Shed Skin documentation &#8212; shedskin 0.9.8 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="prev" title="Shed Skin" href="index.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <section id="shed-skin-documentation">
<h1>Shed Skin documentation<a class="headerlink" href="#shed-skin-documentation" title="Permalink to this headline">¶</a></h1>
<section id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Shed Skin is an experimental Python-to-C++ compiler designed to speed up the execution of computation-intensive Python programs. It converts programs written in a restricted subset of Python to C++. The C++ code can be compiled to executable code, which can be run either as a standalone program or as an extension module that can be imported and used in larger Python programs.</p>
<p>Shed Skin uses type inference techniques to determine the implicit types used in a Python program, in order to generate the explicit type declarations needed in a C++ version. Because C++ is statically typed, Shed Skin requires Python code to be written such that all variables are (implicitly!) statically typed.</p>
<p>Besides the typing and subset restrictions, supported programs cannot freely use the Python standard library, although about 30 common modules are (partially) supported, such as <code class="code docutils literal notranslate"><span class="pre">random</span></code> and <code class="code docutils literal notranslate"><span class="pre">re</span></code> (see <a class="reference internal" href="#library-limitations">Library limitations</a>).</p>
<p>Additionally, the type inference techniques employed by Shed Skin currently do not scale very well beyond several thousand lines of code (the largest compiled program is about 6,000 lines (sloccount)). In all, this means that Shed Skin is currently mostly useful to compile smallish programs and extension modules, that do not make extensive use of dynamic Python features or the standard or external libraries.</p>
<p>Because Shed Skin is still in an early stage of development, it can also improve a lot. At the moment, you will probably run into some bugs when using it. Please report these, so they can be fixed!</p>
</section>
<section id="typing-restrictions">
<h2>Typing restrictions<a class="headerlink" href="#typing-restrictions" title="Permalink to this headline">¶</a></h2>
<p>Shed Skin translates pure, but implicitly statically typed, Python programs into C++. The static typing restriction means that variables can only ever have a single, static type. So, for example,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">a</span> <span class="o">=</span> <span class="s1">&#39;1&#39;</span> <span class="c1"># bad</span>
</pre></div>
</div>
<p>is not allowed. However, as in C++, types can be abstract, so that for example,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="n">A</span><span class="p">()</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">B</span><span class="p">()</span> <span class="c1"># good</span>
</pre></div>
</div>
<p>where A and B have a common base class, is allowed.</p>
<p>The typing restriction also means that the elements of some collection (list, set, etc.) cannot have different types (because their subtype must also be static). Thus:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;apple&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">]</span> <span class="c1"># good</span>
<span class="n">b</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="c1"># good</span>
<span class="n">c</span> <span class="o">=</span> <span class="p">[[</span><span class="mf">10.3</span><span class="p">,</span> <span class="o">-</span><span class="mf">2.0</span><span class="p">],</span> <span class="p">[</span><span class="mf">1.5</span><span class="p">,</span> <span class="mf">2.3</span><span class="p">],</span> <span class="p">[]]</span> <span class="c1"># good</span>
</pre></div>
</div>
<p>is allowed, but</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">d</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mf">2.5</span><span class="p">,</span> <span class="s1">&#39;abc&#39;</span><span class="p">]</span> <span class="c1"># bad</span>
<span class="n">e</span> <span class="o">=</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]]</span> <span class="c1"># bad</span>
<span class="n">f</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;abc&#39;</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span> <span class="c1"># bad</span>
</pre></div>
</div>
<p>is not allowed. Dictionary keys and values may be of different types:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">g</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;a&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">}</span> <span class="c1"># good</span>
<span class="n">h</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;a&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">:</span> <span class="s1">&#39;hello&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]}</span> <span class="c1"># bad</span>
</pre></div>
</div>
<p>In the current version of Shed Skin, mixed types are also permitted in tuples of length two:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="c1"># good</span>
</pre></div>
</div>
<p>In the future, mixed tuples up to a certain length will probably be allowed.</p>
<p>None may only be mixed with non-scalar types (i.e., not with int, float, bool or complex):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">l</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">l</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># good</span>

<span class="n">m</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">m</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># bad</span>

<span class="k">def</span> <span class="nf">fun</span><span class="p">(</span><span class="n">x</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> <span class="c1"># bad: use a special value for x here, e.g. x = -1</span>
    <span class="k">pass</span>
<span class="n">fun</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Integers and floats can usually be mixed (the integers become floats). Shed Skin should complain in cases where they can’t.</p>
</section>
<section id="python-subset-restrictions">
<h2>Python subset restrictions<a class="headerlink" href="#python-subset-restrictions" title="Permalink to this headline">¶</a></h2>
<p>Shed Skin will only ever support a subset of all Python features. The following common features are currently not supported:</p>
<ul class="simple">
<li><p><code class="code docutils literal notranslate"><span class="pre">eval</span></code>, <code class="code docutils literal notranslate"><span class="pre">getattr</span></code>, <code class="code docutils literal notranslate"><span class="pre">hasattr</span></code>, <code class="code docutils literal notranslate"><span class="pre">isinstance</span></code>, anything really dynamic</p></li>
<li><p>arbitrary-size arithmetic (integers become 32-bit (signed) by default on most architectures, see <a class="reference internal" href="#command-line-options">Command-line options</a>)</p></li>
<li><p>argument (un)packing (<code class="code docutils literal notranslate"><span class="pre">*args</span></code> and <code class="code docutils literal notranslate"><span class="pre">**kwargs</span></code>)</p></li>
<li><p>multiple inheritance</p></li>
<li><p>nested functions and classes</p></li>
<li><p>full unicode support (currently restricted to 1-byte characters)</p></li>
<li><p>inheritance from builtins (excluding <code class="code docutils literal notranslate"><span class="pre">Exception</span></code> and <code class="code docutils literal notranslate"><span class="pre">object</span></code>)</p></li>
<li><p>overloading <code class="code docutils literal notranslate"><span class="pre">__iter__</span></code>, <code class="code docutils literal notranslate"><span class="pre">__call__</span></code>, <code class="code docutils literal notranslate"><span class="pre">__del__</span></code></p></li>
<li><p>closures</p></li>
</ul>
<p>Some other features are currently only partially supported:</p>
<ul class="simple">
<li><p>class attributes must always be accessed using a class identifier:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="bp">self</span><span class="o">.</span><span class="n">class_attr</span> <span class="c1"># bad</span>
<span class="n">SomeClass</span><span class="o">.</span><span class="n">class_attr</span> <span class="c1"># good</span>
<span class="n">SomeClass</span><span class="o">.</span><span class="n">some_static_method</span><span class="p">()</span> <span class="c1"># good</span>
</pre></div>
</div>
<ul class="simple">
<li><p>function references can be passed around, but not method references or class references, and they cannot be contained:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="n">x</span><span class="o">+</span><span class="n">y</span> <span class="c1"># good</span>
<span class="n">var</span> <span class="o">=</span> <span class="n">some_func</span> <span class="c1"># good</span>
<span class="n">var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">some_method</span> <span class="c1"># bad, method reference</span>
<span class="n">var</span> <span class="o">=</span> <span class="n">SomeClass</span> <span class="c1"># bad</span>
<span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="c1"># bad, contained</span>
</pre></div>
</div>
</section>
<section id="library-limitations">
<h2>Library limitations<a class="headerlink" href="#library-limitations" title="Permalink to this headline">¶</a></h2>
<p>At the moment, the following 30 modules are (fully or partially) supported. Several of these, such as <code class="code docutils literal notranslate"><span class="pre">os.path</span></code>, were compiled to C++ using Shed Skin.</p>
<ul class="simple">
<li><p><code class="code docutils literal notranslate"><span class="pre">array</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">binascii</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">bisect</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">collections</span></code> (defaultdict, deque)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">colorsys</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">configparser</span></code> (no SafeConfigParser)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">copy</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">csv</span></code> (no Dialect, Sniffer)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">datetime</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">fnmatch</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">functools</span></code> (reduce)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">gc</span></code> (enable, disable, collect)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">getopt</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">glob</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">heapq</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">io</span></code> (only BytesIO)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">itertools</span></code> (no accumulate, pairwise, starmap)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">math</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">mmap</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">os</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">os.path</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">random</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">re</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">select</span></code> (only select function)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">socket</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">string</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">struct</span></code> (no Struct, iter_unpack)</p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">sys</span></code></p></li>
<li><p><code class="code docutils literal notranslate"><span class="pre">time</span></code></p></li>
</ul>
<p>Note that any other module, such as <code class="code docutils literal notranslate"><span class="pre">pygame</span></code>, <code class="code docutils literal notranslate"><span class="pre">pyqt</span></code> or <code class="code docutils literal notranslate"><span class="pre">pickle</span></code>, may be used in combination with a Shed Skin generated extension module. For examples of this, see the <a class="reference external" href="https://github.com/shedskin/shedskin/tree/master/examples">Shed Skin examples</a>.</p>
<p>See <a class="reference internal" href="#how-to-help-out-in-development">How to help out in development</a> on how to help improve or add to the set of supported modules.</p>
</section>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<section id="gnu-linux">
<h3>GNU/Linux<a class="headerlink" href="#gnu-linux" title="Permalink to this headline">¶</a></h3>
<section id="from-distribution">
<h4>From Distribution<a class="headerlink" href="#from-distribution" title="Permalink to this headline">¶</a></h4>
<p>Example command for when using Ubuntu:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="n">shedskin</span>
</pre></div>
</div>
</section>
<section id="manual-installation">
<h4>Manual installation<a class="headerlink" href="#manual-installation" title="Permalink to this headline">¶</a></h4>
<p>To manually install the UNIX tarball, take the following steps:</p>
<ul class="simple">
<li><p>download and unpack tarball</p></li>
<li><p>run:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">install</span>
</pre></div>
</div>
<section id="dependencies">
<h5>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h5>
<p>To compile and run programs produced by shedskin the following libraries are needed:</p>
<ul class="simple">
<li><p>g++, the C++ compiler (version 4.2 or higher).</p></li>
<li><p>pcre development files</p></li>
<li><p>Python development files</p></li>
<li><p>Boehm garbage collection</p></li>
</ul>
<p>To install these libraries under Ubuntu, type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="n">g</span><span class="o">++</span> <span class="n">libpcre</span><span class="o">++-</span><span class="n">dev</span> <span class="n">python</span><span class="o">-</span><span class="nb">all</span><span class="o">-</span><span class="n">dev</span> <span class="n">libgc</span><span class="o">-</span><span class="n">dev</span>
</pre></div>
</div>
<p>If the Boehm garbage collector is not available via your package manager, the following is known to work. Download for example version 7.2alpha6 from the <a class="reference external" href="http://www.hboehm.info/gc/">website</a>, unpack it, and install it as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">configure</span> <span class="o">--</span><span class="n">prefix</span><span class="o">=/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">threads</span><span class="o">=</span><span class="n">posix</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">cplusplus</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">thread</span><span class="o">-</span><span class="n">local</span><span class="o">-</span><span class="n">alloc</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">large</span><span class="o">-</span><span class="n">config</span>
<span class="n">make</span>
<span class="n">make</span> <span class="n">check</span>
<span class="n">sudo</span> <span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
<p>If the PCRE library is not available via your package manager, the following is known to work. Download for example version 8.12 from the <a class="reference external" href="http://www.pcre.org/">website</a>, unpack it, and build as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">configure</span> <span class="o">--</span><span class="n">prefix</span><span class="o">=/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span>
<span class="n">make</span>
<span class="n">sudo</span> <span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
</section>
</section>
</section>
<section id="osx">
<h3>OSX<a class="headerlink" href="#osx" title="Permalink to this headline">¶</a></h3>
<section id="id1">
<h4>Manual installation<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h4>
<p>To install the UNIX tarball on an <strong>OSX</strong> system, take the following steps:</p>
<ul class="simple">
<li><p>download and unpack tarball</p></li>
<li><p>run:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">python</span> <span class="n">setup</span><span class="o">.</span><span class="n">py</span> <span class="n">install</span>
</pre></div>
</div>
<section id="id2">
<h5>Dependencies<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h5>
<p>To compile and run programs produced by shedskin the following libraries are needed:</p>
<ul class="simple">
<li><p>g++, the C++ compiler (version 4.2 or higher; comes with the Apple XCode development environment?)</p></li>
<li><p>pcre development files</p></li>
<li><p>Python development files</p></li>
<li><p>Boehm garbage collection</p></li>
</ul>
<p>If the Boehm garbage collector is not available via your package manager, the following is known to work. Download for example version 7.2alpha6 from the <a class="reference external" href="http://www.hboehm.info/gc/">website</a>, unpack it, and install it as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">configure</span> <span class="o">--</span><span class="n">prefix</span><span class="o">=/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">threads</span><span class="o">=</span><span class="n">posix</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">cplusplus</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">thread</span><span class="o">-</span><span class="n">local</span><span class="o">-</span><span class="n">alloc</span> <span class="o">--</span><span class="n">enable</span><span class="o">-</span><span class="n">large</span><span class="o">-</span><span class="n">config</span>
<span class="n">make</span>
<span class="n">make</span> <span class="n">check</span>
<span class="n">sudo</span> <span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
<p>If the PCRE library is not available via your package manager, the following is known to work. Download for example version 8.12 from the <a class="reference external" href="http://www.pcre.org/">website</a>, unpack it, and build as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">./</span><span class="n">configure</span> <span class="o">--</span><span class="n">prefix</span><span class="o">=/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span>
<span class="n">make</span>
<span class="n">sudo</span> <span class="n">make</span> <span class="n">install</span>
</pre></div>
</div>
</section>
</section>
</section>
<section id="windows">
<h3>Windows<a class="headerlink" href="#windows" title="Permalink to this headline">¶</a></h3>
<p>Install the following dependencies:</p>
<ul class="simple">
<li><p>Microsoft Visual Studio Build Tools (enable CMake in installation process)</p></li>
<li><p>CMake</p></li>
<li><p>Conan 1.62.0 (pip install ‘conan==1.62.0’)</p></li>
</ul>
</section>
</section>
<section id="compiling-a-standalone-program">
<h2>Compiling a standalone program<a class="headerlink" href="#compiling-a-standalone-program" title="Permalink to this headline">¶</a></h2>
<p>To compile the following simple test program, called <code class="docutils literal notranslate"><span class="pre">test.py</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">&#39;hello, world!&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Under Linux/macOS, type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">build</span> <span class="n">test</span>
</pre></div>
</div>
<p>This will create a <code class="docutils literal notranslate"><span class="pre">build</span></code> directory, containing the generated C++ code and binary.</p>
<p>Under Windows (note that this will download dependencies), type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">build</span> <span class="o">--</span><span class="n">conan</span> <span class="n">test</span>
</pre></div>
</div>
<p>Under Linux/macOS, the binary is named <code class="docutils literal notranslate"><span class="pre">build/test</span></code>. Under Windows, it is named
<code class="docutils literal notranslate"><span class="pre">build/Debug/test.exe</span></code>.</p>
</section>
<section id="generating-an-extension-module">
<h2>Generating an extension module<a class="headerlink" href="#generating-an-extension-module" title="Permalink to this headline">¶</a></h2>
<p>To compile the following program, called <code class="docutils literal notranslate"><span class="pre">simple_module.py</span></code>, as an extension module:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># simple_module.py</span>

<span class="k">def</span> <span class="nf">func1</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>

<span class="k">def</span> <span class="nf">func2</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
    <span class="n">d</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">([(</span><span class="n">i</span><span class="p">,</span> <span class="n">i</span><span class="o">*</span><span class="n">i</span><span class="p">)</span>  <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">)])</span>
    <span class="k">return</span> <span class="n">d</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">func1</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">func2</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span>
</pre></div>
</div>
<p>Type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">build</span> <span class="o">-</span><span class="n">e</span> <span class="n">simple_module</span>
</pre></div>
</div>
<p>For this to succeed, make sure to have the Python development files installed (under <strong>Debian</strong>, install <code class="docutils literal notranslate"><span class="pre">python-dev</span></code>; under <strong>Fedora</strong>, install <code class="docutils literal notranslate"><span class="pre">python-devel</span></code>).</p>
<p>Note that for type inference to be possible, the module must (indirectly) call its own functions. This is accomplished in the example by putting the function calls under the <code class="code docutils literal notranslate"><span class="pre">if</span> <span class="pre">__name__=='__main__'</span></code> statement, so that they are not executed when the module is imported. Functions only have to be called indirectly, so if func2 calls func1, the call to func1 can be omitted.</p>
<p>The extension module can now be simply imported and used as usual (first change to <code class="docutils literal notranslate"><span class="pre">build/</span></code> under Linux/macOS, or <code class="docutils literal notranslate"><span class="pre">build/Debug</span></code> under Windows):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">simple_module</span> <span class="kn">import</span> <span class="n">func1</span><span class="p">,</span> <span class="n">func2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">func1</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
<span class="go">6</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">func2</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span>
<span class="go">{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}</span>
</pre></div>
</div>
<section id="limitations">
<h3>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h3>
<p>There are some important differences between using the compiled extension module and the original.</p>
<ol class="arabic simple">
<li><p>Only builtin scalar and container types (<code class="code docutils literal notranslate"><span class="pre">int</span></code>, <code class="code docutils literal notranslate"><span class="pre">float</span></code>, <code class="code docutils literal notranslate"><span class="pre">complex</span></code>, <code class="code docutils literal notranslate"><span class="pre">bool</span></code>, <code class="code docutils literal notranslate"><span class="pre">str</span></code>, <code class="code docutils literal notranslate"><span class="pre">bytes</span></code>, <code class="code docutils literal notranslate"><span class="pre">bytearray</span></code>, <code class="code docutils literal notranslate"><span class="pre">list</span></code>, <code class="code docutils literal notranslate"><span class="pre">tuple</span></code>, <code class="code docutils literal notranslate"><span class="pre">dict</span></code>, <code class="code docutils literal notranslate"><span class="pre">set</span></code>) as well as <code class="code docutils literal notranslate"><span class="pre">None</span></code> and instances of user-defined classes can be passed/returned. So for instance, anonymous functions and iterators are currently not supported.</p></li>
<li><p>Builtin objects are completely converted for each call/return from Shed Skin to CPython types and back, including their contents. This means you cannot change CPython builtin objects from the Shed Skin side and vice versa, and conversion may be slow. Instances of user-defined classes can be passed/returned without any conversion, and changed from either side.</p></li>
<li><p>Global variables are converted once, at initialization time, from Shed Skin to CPython. This means that the value of the CPython version and Shed Skin version can change independently. This problem can be avoided by only using constant globals, or by adding getter/setter functions.</p></li>
<li><p>Multiple (interacting) extension modules are not supported at the moment. Also, importing and using the Python version of a module and the compiled version at the same time may not work.</p></li>
</ol>
</section>
<section id="numpy-integration">
<h3>Numpy integration<a class="headerlink" href="#numpy-integration" title="Permalink to this headline">¶</a></h3>
<p>Shed Skin does not currently come with direct support for Numpy. It is possible however to pass a Numpy array to a Shed Skin compiled extension module as a list, using its <code class="code docutils literal notranslate"><span class="pre">tolist</span></code> method. Note that this is very inefficient (see above), so it is only useful if a relatively large amount of time is spent inside the extension module. Consider the following example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># simple_module2.py</span>

<span class="k">def</span> <span class="nf">my_sum</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; compute sum of elements in list of lists (matrix) &quot;&quot;&quot;</span>
    <span class="n">h</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="c1"># number of rows in matrix</span>
    <span class="n">w</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1"># number of columns</span>
    <span class="n">s</span> <span class="o">=</span> <span class="mf">0.0</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">h</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">w</span><span class="p">):</span>
            <span class="n">s</span> <span class="o">+=</span> <span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">s</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">my_sum</span><span class="p">([[</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">],</span> <span class="p">[</span><span class="mf">3.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">]]))</span>
</pre></div>
</div>
<p>After compiling this module as an extension module with Shed Skin, we can pass in a Numpy array as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">simple_module2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">array</span><span class="p">(([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">2.0</span><span class="p">],</span> <span class="p">[</span><span class="mf">3.0</span><span class="p">,</span> <span class="mf">4.0</span><span class="p">]))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">simple_module2</span><span class="o">.</span><span class="n">my_sum</span><span class="p">(</span><span class="n">a</span><span class="o">.</span><span class="n">tolist</span><span class="p">())</span>
<span class="go">10.0</span>
</pre></div>
</div>
</section>
</section>
<section id="distributing-binaries">
<h2>Distributing binaries<a class="headerlink" href="#distributing-binaries" title="Permalink to this headline">¶</a></h2>
<p>To use a generated (linux/OSX) binary on another system, make sure <code class="docutils literal notranslate"><span class="pre">libgc</span></code> and <code class="docutils literal notranslate"><span class="pre">libpcre3</span></code> are installed there. If they are not, and you cannot install them globally, you can place copies of these libraries into the same directory as the binary, using the following approach:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ldd test
libgc.so.1 =&gt; /usr/lib/libgc.so.1
libpcre.so.3 =&gt; /lib/x86_64-linux-gnu/libpcre.so.3
$ cp /usr/lib/libgc.so.1 .
$ cp /lib/x86_64-linux-gnu/libpcre.so.3 .
$ LD_LIBRARY_PATH=. ./test
</pre></div>
</div>
<p>Note that both systems have to be 32- or 64-bit for this to work. If not, Shed Skin must be installed on the other system, to recompile the binary.</p>
</section>
<section id="multiprocessing">
<h2>Multiprocessing<a class="headerlink" href="#multiprocessing" title="Permalink to this headline">¶</a></h2>
<p>Suppose we have defined the following function in a file, called <code class="docutils literal notranslate"><span class="pre">meuk.py</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">part_sum</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; calculate partial sum &quot;&quot;&quot;</span>
    <span class="nb">sum</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">x</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="nb">sum</span> <span class="o">-=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">x</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="nb">sum</span> <span class="o">+=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">x</span>
    <span class="k">return</span> <span class="nb">sum</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
    <span class="n">part_sum</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</pre></div>
</div>
<p>To compile this into an extension module, type:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">build</span> <span class="o">-</span><span class="n">e</span> <span class="n">meuk</span>
<span class="n">cp</span> <span class="n">build</span><span class="o">/</span><span class="n">meuk</span><span class="o">.</span><span class="n">so</span> <span class="o">.</span>
</pre></div>
</div>
<p>To use the generated extension module with the <code class="code docutils literal notranslate"><span class="pre">multiprocessing</span></code> standard library module, simply add a pure-Python wrapper:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">multiprocessing</span> <span class="kn">import</span> <span class="n">Pool</span>

<span class="k">def</span> <span class="nf">part_sum</span><span class="p">((</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">)):</span>
    <span class="kn">import</span> <span class="nn">meuk</span>
    <span class="k">return</span> <span class="n">meuk</span><span class="o">.</span><span class="n">part_sum</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">)</span>

<span class="n">pool</span> <span class="o">=</span> <span class="n">Pool</span><span class="p">(</span><span class="n">processes</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="nb">sum</span><span class="p">(</span><span class="n">pool</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">part_sum</span><span class="p">,</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10000000</span><span class="p">),</span> <span class="p">(</span><span class="mi">10000001</span><span class="p">,</span> <span class="mi">20000000</span><span class="p">)])))</span>
</pre></div>
</div>
</section>
<section id="calling-c-c-code">
<h2>Calling C/C++ code<a class="headerlink" href="#calling-c-c-code" title="Permalink to this headline">¶</a></h2>
<p>To call manually written C/C++ code, follow these steps:</p>
<ul class="simple">
<li><p>Provide Shed Skin with enough information to perform type inference, by providing it with a <em>type model</em> of the C/C++ code. Suppose we wish to call a simple function that returns a list with the n smallest prime numbers larger than some number. The following type model, contained in a file called <code class="docutils literal notranslate"><span class="pre">stuff.py</span></code>, is sufficient for Shed Skin to perform type inference:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#stuff.py</span>

<span class="k">def</span> <span class="nf">more_primes</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">nr</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
    <span class="k">return</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span>
</pre></div>
</div>
<ul class="simple">
<li><p>To actually perform type inference, create a test program, called <code class="docutils literal notranslate"><span class="pre">test.py</span></code>, that uses the type model, and compile it:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#test.py</span>

<span class="kn">import</span> <span class="nn">stuff</span>
<span class="nb">print</span><span class="p">(</span><span class="n">stuff</span><span class="o">.</span><span class="n">more_primes</span><span class="p">(</span><span class="mi">100</span><span class="p">))</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">build</span> <span class="n">test</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Besides <code class="docutils literal notranslate"><span class="pre">test.py</span></code>, this also compiles <code class="docutils literal notranslate"><span class="pre">stuff.py</span></code> to C++. Now you can fill in manual C/C++ code in <code class="docutils literal notranslate"><span class="pre">stuff.cpp</span></code>. To avoid that it is overwritten the next time <code class="docutils literal notranslate"><span class="pre">test.py</span></code> is compiled, move <code class="docutils literal notranslate"><span class="pre">stuff.*</span></code> to the Shed Skin <code class="docutils literal notranslate"><span class="pre">lib/</span></code> dir.</p></li>
</ul>
<section id="standard-library">
<h3>Standard library<a class="headerlink" href="#standard-library" title="Permalink to this headline">¶</a></h3>
<p>By moving <code class="docutils literal notranslate"><span class="pre">stuff.*</span></code> to <code class="docutils literal notranslate"><span class="pre">lib/</span></code>, we have in fact added support for an arbitrary library module to Shed Skin. Other programs compiled by Shed Skin can now import <code class="code docutils literal notranslate"><span class="pre">stuff</span></code> and use <code class="code docutils literal notranslate"><span class="pre">more_primes</span></code>. In fact, in the <code class="docutils literal notranslate"><span class="pre">lib/</span></code> directory, you can find type models and implementations for all supported modules. As you may notice, some have been partially converted to C++ using Shed Skin.</p>
</section>
<section id="shed-skin-types">
<h3>Shed Skin types<a class="headerlink" href="#shed-skin-types" title="Permalink to this headline">¶</a></h3>
<p>Shed Skin reimplements the Python builtins with its own set of C++ classes. These have a similar interface to their Python counterparts, so they should be easy to use (provided you have some basic C++ knowledge.) See the class definitions in <code class="docutils literal notranslate"><span class="pre">lib/builtin.hpp</span></code> for details. If in doubt, convert some equivalent Python code to C++, and have a look at the result!</p>
</section>
</section>
<section id="command-line-options">
<h2>Command-line options<a class="headerlink" href="#command-line-options" title="Permalink to this headline">¶</a></h2>
<p>shedskin has recently adopted a command-line api with subcommands:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ shedskin --help
usage: shedskin [-h] {analyze,translate,build,run,test} ...

Restricted-Python-to-C++ Compiler

options:
  -h, --help            show this help message and exit

subcommands:
    analyze             analyze and validate python module
    translate           translate python module to cpp
    build               build translated module
    run                 run built and translated module
    test                run tests
</pre></div>
</div>
<p>The historical behaviour is provided by the <cite>translate</cite> subcommand,
with the other commands except <cite>analyze</cite> requiring <a class="reference external" href="https://cmake.org/">cmake</a> to work.</p>
<section id="analyze">
<h3>analyze<a class="headerlink" href="#analyze" title="Permalink to this headline">¶</a></h3>
<p>The <cite>analyze</cite> command is intended to provided analysis and validation of a shedskin target without code-generation.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ shedskin analyze --help
usage: shedskin analyze [-h] name

positional arguments:
  name        Python file or module to analyze

options:
  -h, --help  show this help message and exit
</pre></div>
</div>
</section>
<section id="translate">
<h3>translate<a class="headerlink" href="#translate" title="Permalink to this headline">¶</a></h3>
<p>The shedskin translate command can be given the following options:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">usage</span><span class="p">:</span> <span class="n">shedskin</span> <span class="n">translate</span> <span class="p">[</span><span class="o">-</span><span class="n">h</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">a</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">d</span> <span class="n">DEBUG</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">e</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">f</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">F</span> <span class="n">FLAGS</span><span class="p">]</span>
                          <span class="p">[</span><span class="o">-</span><span class="n">L</span> <span class="p">[</span><span class="n">LIB</span> <span class="o">...</span><span class="p">]]</span> <span class="p">[</span><span class="o">-</span><span class="n">l</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">m</span> <span class="n">MAKEFILE</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">o</span> <span class="n">OUTPUTDIR</span><span class="p">]</span>
                          <span class="p">[</span><span class="o">-</span><span class="n">r</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">s</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">x</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span><span class="n">noassert</span><span class="p">]</span> <span class="p">[</span><span class="o">-</span><span class="n">b</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span><span class="n">nogc</span><span class="p">]</span>
                          <span class="p">[</span><span class="o">--</span><span class="n">nogcwarns</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span><span class="n">nomakefile</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span><span class="n">nowrap</span><span class="p">]</span>
                          <span class="n">name</span>

<span class="n">positional</span> <span class="n">arguments</span><span class="p">:</span>
  <span class="n">name</span>                  <span class="n">Python</span> <span class="n">file</span> <span class="ow">or</span> <span class="n">module</span> <span class="n">to</span> <span class="nb">compile</span>

<span class="n">options</span><span class="p">:</span>
  <span class="o">-</span><span class="n">h</span><span class="p">,</span> <span class="o">--</span><span class="n">help</span>            <span class="n">show</span> <span class="n">this</span> <span class="n">help</span> <span class="n">message</span> <span class="ow">and</span> <span class="n">exit</span>
  <span class="o">-</span><span class="n">a</span><span class="p">,</span> <span class="o">--</span><span class="n">ann</span>             <span class="n">Output</span> <span class="n">annotated</span> <span class="n">source</span> <span class="n">code</span> <span class="p">(</span><span class="o">.</span><span class="n">ss</span><span class="o">.</span><span class="n">py</span><span class="p">)</span>
  <span class="o">-</span><span class="n">d</span> <span class="n">DEBUG</span><span class="p">,</span> <span class="o">--</span><span class="n">debug</span> <span class="n">DEBUG</span>
                        <span class="n">Set</span> <span class="n">debug</span> <span class="n">level</span>
  <span class="o">-</span><span class="n">e</span><span class="p">,</span> <span class="o">--</span><span class="n">extmod</span>          <span class="n">Generate</span> <span class="n">extension</span> <span class="n">module</span>
  <span class="o">-</span><span class="n">f</span><span class="p">,</span> <span class="o">--</span><span class="nb">float</span>           <span class="n">Use</span> <span class="mi">32</span><span class="o">-</span><span class="n">bit</span> <span class="n">floating</span> <span class="n">point</span> <span class="n">numbers</span>
  <span class="o">-</span><span class="n">F</span> <span class="n">FLAGS</span><span class="p">,</span> <span class="o">--</span><span class="n">flags</span> <span class="n">FLAGS</span>
                        <span class="n">Provide</span> <span class="n">alternate</span> <span class="n">Makefile</span> <span class="n">flags</span>
  <span class="o">-</span><span class="n">L</span> <span class="p">[</span><span class="n">LIB</span> <span class="o">...</span><span class="p">],</span> <span class="o">--</span><span class="n">lib</span> <span class="p">[</span><span class="n">LIB</span> <span class="o">...</span><span class="p">]</span>
                        <span class="n">Add</span> <span class="n">a</span> <span class="n">library</span> <span class="n">directory</span>
  <span class="o">-</span><span class="n">l</span><span class="p">,</span> <span class="o">--</span><span class="n">long</span>            <span class="n">Use</span> <span class="n">long</span> <span class="n">long</span> <span class="s1">&#39;64-bit&#39;</span> <span class="n">integers</span>
  <span class="o">-</span><span class="n">m</span> <span class="n">MAKEFILE</span><span class="p">,</span> <span class="o">--</span><span class="n">makefile</span> <span class="n">MAKEFILE</span>
                        <span class="n">Specify</span> <span class="n">alternate</span> <span class="n">Makefile</span> <span class="n">name</span>
  <span class="o">-</span><span class="n">o</span> <span class="n">OUTPUTDIR</span><span class="p">,</span> <span class="o">--</span><span class="n">outputdir</span> <span class="n">OUTPUTDIR</span>
                        <span class="n">Specify</span> <span class="n">output</span> <span class="n">directory</span> <span class="k">for</span> <span class="n">generated</span> <span class="n">files</span>
  <span class="o">-</span><span class="n">r</span><span class="p">,</span> <span class="o">--</span><span class="n">random</span>          <span class="n">Use</span> <span class="n">fast</span> <span class="n">random</span> <span class="n">number</span> <span class="n">generator</span> <span class="p">(</span><span class="n">rand</span><span class="p">())</span>
  <span class="o">-</span><span class="n">s</span><span class="p">,</span> <span class="o">--</span><span class="n">silent</span>          <span class="n">Silent</span> <span class="n">mode</span><span class="p">,</span> <span class="n">only</span> <span class="n">show</span> <span class="n">warnings</span>
  <span class="o">-</span><span class="n">x</span><span class="p">,</span> <span class="o">--</span><span class="n">traceback</span>       <span class="n">Print</span> <span class="n">traceback</span> <span class="k">for</span> <span class="n">uncaught</span> <span class="n">exceptions</span>
  <span class="o">--</span><span class="n">noassert</span>            <span class="n">Disable</span> <span class="k">assert</span> <span class="n">statements</span>
  <span class="o">-</span><span class="n">b</span><span class="p">,</span> <span class="o">--</span><span class="n">nobounds</span>        <span class="n">Disable</span> <span class="n">bounds</span> <span class="n">checking</span>
  <span class="o">--</span><span class="n">nogc</span>                <span class="n">Disable</span> <span class="n">garbage</span> <span class="n">collection</span>
  <span class="o">--</span><span class="n">nogcwarns</span>           <span class="n">Disable</span> <span class="n">runtime</span> <span class="n">GC</span> <span class="n">warnings</span>
  <span class="o">--</span><span class="n">nomakefile</span>          <span class="n">Disable</span> <span class="n">makefile</span> <span class="n">generation</span>
  <span class="o">--</span><span class="n">nowrap</span>              <span class="n">Disable</span> <span class="n">wrap</span><span class="o">-</span><span class="n">around</span> <span class="n">checking</span>
</pre></div>
</div>
<p>For example, to compile the file <code class="docutils literal notranslate"><span class="pre">test.py</span></code> as an extension module, type</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>shedskin translate –e test
</pre></div>
</div>
<p>or</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>shedskin translate ––extmod test
</pre></div>
</div>
<p>Using <code class="code docutils literal notranslate"><span class="pre">-b</span></code> or <code class="code docutils literal notranslate"><span class="pre">--nobounds</span></code> is also very common, as it disables out-of-bounds exceptions (<code class="code docutils literal notranslate"><span class="pre">IndexError</span></code>), which can have a large impact on performance.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">a</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="nb">print</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">5</span><span class="p">])</span> <span class="c1"># invalid index: out of bounds</span>
</pre></div>
</div>
</section>
<section id="build">
<h3>build<a class="headerlink" href="#build" title="Permalink to this headline">¶</a></h3>
<p>The <cite>build</cite> command calls <cite>shedskin translate</cite> on a target via cmake, generates a suitable <cite>CMakeLists.txt</cite> file
and then builds it, placing build artefacts in a <cite>build</cite> directory.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ shedskin build --help
usage: shedskin build [-h] [--generator G] [--jobs N] [--build-type T] [--test] [--reset] [--conan]
                      [--spm] [--extproject] [--ccache] [--target TARGET [TARGET ...]] [-a]
                      [-d DEBUG] [-e] [-f] [-F FLAGS] [-L [LIB ...]] [-l] [-m MAKEFILE]
                      [-o OUTPUTDIR] [-r] [-s] [-x] [--noassert] [--nobounds] [--nogc] [--nogcwarns]
                      [--nomakefile] [--nowrap]
                      name

positional arguments:
  name                  Python file or module to compile

options:
  -h, --help            show this help message and exit
  --generator G         specify a cmake build system generator
  --jobs N              build and run in parallel using N jobs
  --build-type T        set cmake build type (default: &#39;Debug&#39;)
  --test                run ctest
  --reset               reset cmake build
  --conan               install cmake dependencies with conan
  --spm                 install cmake dependencies with spm
  --extproject          install cmake dependencies with externalproject
  --ccache              enable ccache with cmake
  --target TARGET [TARGET ...]
                        build only specified cmake targets
  -a, --ann             Output annotated source code (.ss.py)
  -d DEBUG, --debug DEBUG
                        Set debug level
  -e, --extmod          Generate extension module
  -f, --float           Use 32-bit floating point numbers
  -F FLAGS, --flags FLAGS
                        Provide alternate Makefile flags
  -L [LIB ...], --lib [LIB ...]
                        Add a library directory
  -l, --long            Use long long &#39;64-bit&#39; integers
  -m MAKEFILE, --makefile MAKEFILE
                        Specify alternate Makefile name
  -o OUTPUTDIR, --outputdir OUTPUTDIR
                        Specify output directory for generated files
  -r, --random          Use fast random number generator (rand())
  -s, --silent          Silent mode, only show warnings
  -x, --traceback       Print traceback for uncaught exceptions
  --noassert            Disable assert statements
  --nobounds            Disable bounds checking
  --nogc                Disable garbage collection
  --nogcwarns           Disable runtime GC warnings
  --nomakefile          Disable makefile generation
  --nowrap              Disable wrap-around checking
</pre></div>
</div>
</section>
<section id="run">
<h3>run<a class="headerlink" href="#run" title="Permalink to this headline">¶</a></h3>
<p>The <cite>run</cite> command does everything the <cite>build</cite> command does and then runs the resultant executable.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ shedskin run --help
usage: shedskin run [-h] [--generator G] [--jobs N] [--build-type T] [--test] [--reset] [--conan]
                    [--spm] [--extproject] [--ccache] [--target TARGET [TARGET ...]] [-a] [-d DEBUG]
                    [-e] [-f] [-F FLAGS] [-L [LIB ...]] [-l] [-m MAKEFILE] [-o OUTPUTDIR] [-r] [-s]
                    [-x] [--noassert] [--nobounds] [--nogc] [--nogcwarns] [--nomakefile] [--nowrap]
                    name

positional arguments:
  name                  Python file or module to run

options:
  -h, --help            show this help message and exit
  --generator G         specify a cmake build system generator
  --jobs N              build and run in parallel using N jobs
  --build-type T        set cmake build type (default: &#39;Debug&#39;)
  --test                run ctest
  --reset               reset cmake build
  --conan               install cmake dependencies with conan
  --spm                 install cmake dependencies with spm
  --extproject          install cmake dependencies with externalproject
  --ccache              enable ccache with cmake
  --target TARGET [TARGET ...]
                        build only specified cmake targets
  -a, --ann             Output annotated source code (.ss.py)
  -d DEBUG, --debug DEBUG
                        Set debug level
  -e, --extmod          Generate extension module
  -f, --float           Use 32-bit floating point numbers
  -F FLAGS, --flags FLAGS
                        Provide alternate Makefile flags
  -L [LIB ...], --lib [LIB ...]
                        Add a library directory
  -l, --long            Use long long &#39;64-bit&#39; integers
  -m MAKEFILE, --makefile MAKEFILE
                        Specify alternate Makefile name
  -o OUTPUTDIR, --outputdir OUTPUTDIR
                        Specify output directory for generated files
  -r, --random          Use fast random number generator (rand())
  -s, --silent          Silent mode, only show warnings
  -x, --traceback       Print traceback for uncaught exceptions
  --noassert            Disable assert statements
  --nobounds            Disable bounds checking
  --nogc                Disable garbage collection
  --nogcwarns           Disable runtime GC warnings
  --nomakefile          Disable makefile generation
  --nowrap              Disable wrap-around checking
</pre></div>
</div>
</section>
<section id="test">
<h3>test<a class="headerlink" href="#test" title="Permalink to this headline">¶</a></h3>
<p>The <cite>test`</cite> command provides builtin test discovery and running.</p>
<p>Basically <cite>cd shedskin/tests</cite> or <cite>cd shedskin/examples</cite> and then type the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">test</span>
</pre></div>
</div>
<p>command-line options are extensive:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ shedskin test --help
usage: shedskin test [-h] [-e] [--dryrun] [--include PATTERN] [--check] [--modified] [--nocleanup]
                    [--pytest] [--run TEST] [--stoponfail] [--run-errs] [--progress] [--debug]
                    [--generator G] [--jobs N] [--build-type T] [--reset] [--conan] [--spm]
                    [--extproject] [--ccache] [--target TARGET [TARGET ...]]

options:
  -h, --help            show this help message and exit
  -e, --extmod          Generate extension module
  --dryrun              dryrun without any changes
  --include PATTERN     provide regex of tests to include with cmake
  --check               check testfile py syntax before running
  --modified            run only recently modified test
  --nocleanup           do not cleanup built test
  --pytest              run pytest before each test run
  --run TEST            run single test
  --stoponfail          stop when first failure happens in ctest
  --run-errs            run error/warning message tests
  --progress            enable short progress output from ctest
  --debug               set cmake debug on
  --generator G         specify a cmake build system generator
  --jobs N              build and run in parallel using N jobs
  --build-type T        set cmake build type (default: &#39;Debug&#39;)
  --reset               reset cmake build
  --conan               install cmake dependencies with conan
  --spm                 install cmake dependencies with spm
  --extproject          install cmake dependencies with externalproject
  --ccache              enable ccache with cmake
  --target TARGET [TARGET ...]
                        build only specified cmake targets
</pre></div>
</div>
</section>
</section>
<section id="performance-tips-and-tricks">
<span id="performance-tips"></span><h2>Performance tips and tricks<a class="headerlink" href="#performance-tips-and-tricks" title="Permalink to this headline">¶</a></h2>
<section id="id3">
<h3>Performance tips<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><p>Small memory allocations (e.g. creating a new tuple, list or class instance..) typically do not slow down Python programs by much. However, after compilation to C++, they can quickly become a bottleneck. This is because for each allocation, memory has to be requested from the system, the memory has to be garbage-collected, and many memory allocations are further likely to cause cache misses. The key to getting very good performance is often to reduce the number of small allocations, for example by rewriting a small list comprehension by a for loop or by avoiding intermediate tuples in some calculation.</p></li>
<li><p>But note that for the idiomatic <code class="code docutils literal notranslate"><span class="pre">for</span> <span class="pre">a,</span> <span class="pre">b</span> <span class="pre">in</span> <span class="pre">enumerate(..)</span></code>, <code class="code docutils literal notranslate"><span class="pre">for</span> <span class="pre">a,</span> <span class="pre">b</span> <span class="pre">in</span> <span class="pre">enumerate(..)</span></code> and <code class="code docutils literal notranslate"><span class="pre">for</span> <span class="pre">a,</span> <span class="pre">b</span> <span class="pre">in</span> <span class="pre">somedict.iteritems()</span></code>, the intermediate small objects are optimized away, and that 1-length strings are cached.</p></li>
<li><p>Several Python features (that may slow down generated code) are not always necessary, and can be turned off. See the section <cite>Command-line options</cite> for details. Turning off bounds checking is usually a very safe optimization, and can help a lot for indexing-heavy code.</p></li>
<li><p>Attribute access is faster in the generated code than indexing. For example, <code class="code docutils literal notranslate"><span class="pre">v.x</span> <span class="pre">*</span> <span class="pre">v.y</span> <span class="pre">*</span> <span class="pre">v.z</span></code> is faster than <code class="code docutils literal notranslate"><span class="pre">v[0]</span> <span class="pre">*</span> <span class="pre">v[1]</span> <span class="pre">*</span> <span class="pre">v[2]</span></code>.</p></li>
<li><p>Shed Skin takes the flags it sends to the C++ compiler from the <code class="code docutils literal notranslate"><span class="pre">FLAGS*</span></code> files in the Shed Skin installation directory. These flags can be modified, or overruled by creating a local file named <code class="docutils literal notranslate"><span class="pre">FLAGS</span></code>.</p></li>
<li><p>When doing float-heavy calculations, it is not always necessary to follow exact IEEE floating-point specifications. Avoiding this by adding -ffast-math can sometimes greatly improve performance.</p></li>
<li><p>Profile-guided optimization can help to squeeze out even more performance. For a recent version of GCC, first compile and run the generated code with <code class="code docutils literal notranslate"><span class="pre">-fprofile-generate</span></code>, then with <code class="code docutils literal notranslate"><span class="pre">-fprofile-use</span></code>.</p></li>
<li><p>For best results, configure a recent version of the Boehm GC using <code class="code docutils literal notranslate"><span class="pre">CPPFLAGS=&quot;-O3</span> <span class="pre">-march=native&quot;</span> <span class="pre">./configure</span> <span class="pre">--enable-cplusplus</span> <span class="pre">--enable-threads=pthreads</span> <span class="pre">--enable-thread-local-alloc</span> <span class="pre">--enable-large-config</span> <span class="pre">--enable-parallel-mark</span></code>. The last option allows the GC to take advantage of having multiple cores.</p></li>
<li><p>When optimizing, it is extremely useful to know exactly how much time is spent in each part of your program. The program <a class="reference external" href="https://github.com/jrfonseca/gprof2dot">Gprof2Dot</a> can be used to generate beautiful graphs for a stand-alone program, as well as the original Python code. The program <a class="reference external" href="http://oprofile.sourceforge.net/news/">OProfile</a> can be used to profile an extension module.</p></li>
</ul>
<p>To use Gprof2dot, download <code class="docutils literal notranslate"><span class="pre">gprof2dot.py</span></code> from the website, and install Graphviz. Then:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">translate</span> <span class="n">program</span>
<span class="n">make</span> <span class="n">program_prof</span>
<span class="o">./</span><span class="n">program_prof</span>
<span class="n">gprof</span> <span class="n">program_prof</span> <span class="o">|</span> <span class="n">gprof2dot</span><span class="o">.</span><span class="n">py</span> <span class="o">|</span> <span class="n">dot</span> <span class="o">-</span><span class="n">Tpng</span> <span class="o">-</span><span class="n">ooutput</span><span class="o">.</span><span class="n">png</span>
</pre></div>
</div>
<p>To use OProfile, install it and use it as follows.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">shedskin</span> <span class="n">translate</span> <span class="o">-</span><span class="n">e</span> <span class="n">extmod</span>
<span class="n">make</span>
<span class="n">sudo</span> <span class="n">opcontrol</span> <span class="o">--</span><span class="n">start</span>
<span class="n">python</span> <span class="n">main_program_that_imports_extmod</span>
<span class="n">sudo</span> <span class="n">opcontrol</span> <span class="o">--</span><span class="n">shutdown</span>
<span class="n">opreport</span> <span class="o">-</span><span class="n">l</span> <span class="n">extmod</span><span class="o">.</span><span class="n">so</span>
</pre></div>
</div>
</section>
<section id="tricks">
<h3>Tricks<a class="headerlink" href="#tricks" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><p>The following two code fragments work the same, but only the second one is supported:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">statistics</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;nodes&#39;</span><span class="p">:</span> <span class="mi">28</span><span class="p">,</span> <span class="s1">&#39;solutions&#39;</span><span class="p">:</span> <span class="nb">set</span><span class="p">()}</span>

<span class="k">class</span> <span class="nc">statistics</span><span class="p">:</span> <span class="k">pass</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">statistics</span><span class="p">();</span> <span class="n">s</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="mi">28</span><span class="p">;</span> <span class="n">s</span><span class="o">.</span><span class="n">solutions</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
</pre></div>
</div>
<ul class="simple">
<li><p>The evaluation order of arguments to a function or print changes with translation to C++, so it’s better not to depend on this:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s1">&#39;hoei&#39;</span><span class="p">,</span> <span class="n">raw_input</span><span class="p">())</span> <span class="c1"># raw_input is called before printing &#39;hoei&#39;!</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Tuples with different types of elements and length &gt; 2 are currently not supported. It can however be useful to ‘simulate’ them:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">mytuple</span><span class="p">:</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">b</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">c</span> <span class="o">=</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Block comments surrounded by #{ and #} are ignored by Shed Skin. This can be used to comment out code that cannot be compiled. For example, the following will only produce a plot when run using CPython:</p></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;x =&quot;</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;y =&quot;</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="c1">#{</span>
<span class="kn">import</span> <span class="nn">pylab</span> <span class="k">as</span> <span class="nn">pl</span>
<span class="n">pl</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="n">pl</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
<span class="c1">#}</span>
</pre></div>
</div>
</section>
</section>
<section id="how-to-help-out-in-development">
<h2>How to help out in development<a class="headerlink" href="#how-to-help-out-in-development" title="Permalink to this headline">¶</a></h2>
<p>Open source projects thrive on feedback. Please send in bug reports, patches or other code, or suggestions about this document; or join the mailing list and start or participate in discussions. There is also <a class="reference external" href="https://github.com/shedskin/shedskin/issues?q=is%3Aissue+is%3Aopen+label%3Aeasytask">an “easytask” issue label</a> for possible tasks to start out with.</p>
<p>If you are a student, you might want to consider applying for the yearly Google Summer of Code or GHOP projects. Shed Skin has so far successfully participated in one Summer of Code and one GHOP.</p>
</section>
</section>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">shedskin</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Shed Skin documentation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="#typing-restrictions">Typing restrictions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#python-subset-restrictions">Python subset restrictions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#library-limitations">Library limitations</a></li>
<li class="toctree-l2"><a class="reference internal" href="#installation">Installation</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#gnu-linux">GNU/Linux</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#from-distribution">From Distribution</a></li>
<li class="toctree-l4"><a class="reference internal" href="#manual-installation">Manual installation</a><ul>
<li class="toctree-l5"><a class="reference internal" href="#dependencies">Dependencies</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#osx">OSX</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">Manual installation</a><ul>
<li class="toctree-l5"><a class="reference internal" href="#id2">Dependencies</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#windows">Windows</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#compiling-a-standalone-program">Compiling a standalone program</a></li>
<li class="toctree-l2"><a class="reference internal" href="#generating-an-extension-module">Generating an extension module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#limitations">Limitations</a></li>
<li class="toctree-l3"><a class="reference internal" href="#numpy-integration">Numpy integration</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#distributing-binaries">Distributing binaries</a></li>
<li class="toctree-l2"><a class="reference internal" href="#multiprocessing">Multiprocessing</a></li>
<li class="toctree-l2"><a class="reference internal" href="#calling-c-c-code">Calling C/C++ code</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#standard-library">Standard library</a></li>
<li class="toctree-l3"><a class="reference internal" href="#shed-skin-types">Shed Skin types</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#command-line-options">Command-line options</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#analyze">analyze</a></li>
<li class="toctree-l3"><a class="reference internal" href="#translate">translate</a></li>
<li class="toctree-l3"><a class="reference internal" href="#build">build</a></li>
<li class="toctree-l3"><a class="reference internal" href="#run">run</a></li>
<li class="toctree-l3"><a class="reference internal" href="#test">test</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#performance-tips-and-tricks">Performance tips and tricks</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id3">Performance tips</a></li>
<li class="toctree-l3"><a class="reference internal" href="#tricks">Tricks</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#how-to-help-out-in-development">How to help out in development</a></li>
</ul>
</li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="index.html" title="previous chapter">Shed Skin</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2006—2023, Mark Dufour & the Shed Skin contributors.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 4.3.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/documentation.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>